<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>生成器函数实战1</title>
</head>
<body>
	
	<script>
		function one() {
			setTimeout(function(){
				console.log(1111);
				str.next();
			},1000)
		}

		function two() {
			setTimeout(function(){
				console.log(2222);
				str.next();
			},2000)
		}

		function three() {
			setTimeout(function(){
				console.log(3333);
			},3000)
		}

		function * gen(){
			yield one();
			yield two();
			yield three();
		}

		let str = gen();
		str.next();
	</script>
</body>
</html>